//
//  UIView+Extension.swift
//  Weibo05
//
//  Created by IvesMac on 2017/6/7.
//  Copyright © 2017年 IvesMac. All rights reserved.
//

import UIKit

//  MARK: -- 提供UIView布局的扩展
/// extension不能定义存储属性
extension UIView {
    
    // x坐标
    var x:CGFloat {
        get {
            return frame.origin.x
        } set {
            // newValue,赋予新值
            frame.origin.x = newValue
        }
    }
    
    // y坐标
    var y:CGFloat {
        get {
            return frame.origin.y
        } set {
            // newValue,赋予新值
            frame.origin.y = newValue
        }
    }
    
    // 宽度
    var width:CGFloat {
        get {
            return frame.size.width
        } set {
            // newValue,赋予新值
            frame.size.width = newValue
        }
    }

    // 高度
    var height:CGFloat {
        get {
            return frame.size.height
        } set {
            // newValue,赋予新值
            frame.size.height = newValue
        }
    }

    // size
    var size:CGSize {
        get {
            return frame.size
        } set {
            // newValue,赋予新值
            frame.size = newValue
        }
    }

    // centerX
    var centerX:CGFloat {
        get {
            return center.x
        } set {
            // newValue,赋予新值
            center.x = newValue
        }
    }

    // centerY
    var centerY:CGFloat {
        get {
            return center.y
        } set {
            // newValue,赋予新值
            center.y = newValue
        }
    }

}
